package com.example.weather_forecast;

import java.io.InputStream;
import java.util.List;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

public class ParsewithSAX {
    //解析xml文件返回天气信息的集合
    public static List<WeatherInfo> getInfosFromXMLbySAX (InputStream is) throws Exception {

        SAXParserFactory factory =SAXParserFactory.newInstance();
        SAXParser parser= factory.newSAXParser();
        ParseHandler handler=new ParseHandler();
        parser.parse(is,handler);
        return handler.getInfosFromXMLbySAX();
    }
}
